Using C++ on a Raspberry Pi with Blynk

@GunnerTechTools yes I spotted it.

@Dmitriy and @vshymanskyy the tar for 0.4.4 shows 0.4.3 in and library.json. In fact looking at the dates of the headers it’s all 0.4.3.

That explains all the 0.4.3’s that keep popping up on the forum. Which archive is used by Arduino library manager that I recommend not using?

1 Like

@Costas So as this is C++ and seems almost like working with Arduino, does that mean that it can use some of the same basic libraries and code?

Meanwhile I have the example slightly tweaked to also trip some relays and fade an LED as well as run the client automatically at reboot… finally, coding progress with RPi. Unfortunately, I don’t have a CodeShield type hat to easily provide hardware and sensors to the RPi… and have to keep aware of the 3.3v tolerance when I add my own.

ps, I am learning to really dislike PATH inconsistencies; dozens of ways, some work, some don’t, some work sometimes… arrrggg :stuck_out_tongue: Where is the darn master PATH file stored, so I can edit it and clean it up?? Google hasn’t given it up yet.

On the Pi it’s probably an enviroment variable. It usually resides in your bash_profile (~/.bash_profile or something similar.

Thanks, I will look. I only recently realized that ~/. is just a place holder for part of the path… kept messing me up when looking for stuffs.

Linux, the best way to wrap your head into a pretzel :confounded:

The most difficult aspect, if you ask me, is the user rights system. A Windows operator is basically always local administrator. Linux is a lot more strict with that.

But that is another discussion and I’m not sure this is the right place for that. Though I’d love to help ppl with the Linux parts, I’m not sure there is an appropriate category for that here. Maybe the RasPi needs a separate category, what’d you think @Dmitriy ? Since it’s a kind of “different” product from your basic MCU.

That is why I created this thread. The elitists slate the Arduino implementation of C++ but it’s something that many, many people, me included, are very familiar with. I made the basic example look as much like an Arduino sketch as I was able, even including some parts that are not technically needed.

Yes and no. Obviously a Raspberry Pi is not an Arduino but the underlying C++ code within the libraries can be compiled for most platforms. Arduino made the linking of libraries and compilation so seamless that many users are not aware of the basic processes that are involved. I’m certainly not knocking Arduino for that.

If you study the Makefile you will see the basics of how additional libraries and the required paths are included in the compilation but it’s not a straightforward process and takes some time to get up and running. I just wanted to offer the basic GPIO control as a starter and you will see the millis() hack for timed intervals rather than the preferred SimpleTimer used with Arduino.

I too struggle with paths but I did post a reference to bash_profile a few days ago. More to follow later … long story short, there are a couple nice hints here :slight_smile:

Ah ha! that’s why it looked so strange… but I hadn’t gotten around to digging into it more.

Yup, They both empowered and spoiled the non-elite with quasi coding powers :smiley:

The different versions of linux have broadly similar approaches for the path but as per the recent RPI3 thread at Problem installing in RPi3: onoff library and later the syntax to “permanently” add an entry to the path on a Raspberry Pi takes the following syntax:

echo 'export PATH=$PATH:/opt/nodejs/bin/' >> ~/.bashrc

Having changed the path you can simply edit the .baschrc file with nano at a later date if you wish.

I thought it was time to update my RPi client to latest 0.4.6 library.

However, after downloading, unzipping and much fussing about to get the files where I wanted them. I ran my script just fine… but it still says 0.4.3 both as it starts and according to the Admin Page. But the clearly says 0.4.6.

More typos <–hopeful wishing?? or do I actually have to go through all that file modding and script building after each library upgrade? (ok, similar to Arduino - but much more painful :unamused: )

Of course, that will be real fun this time around, since the upgrade overwrote the main.cpp which of course had my customised script :rage: --> LINUX. Must remember to rename main.cpp to something else next time.

Hey, sorry for that… Yes it’s arduino library removing stuff during updates… So you should build outside the Arduino ide for linux… I will add a note to the docs.

Wait, what? Are you saying I “could - but shouldn’t” build my wiringPi code using Arduino IDE?? I coded everything in the CLI using Nano… a pain, but I didn’t know I could do easily otherwise… I didn’t think it would compile/verify in the IDE anyhow, so I didn’t bother trying.

Or am I just misinterpreting something? Probable… just hearing the work Linux scrambles my brain :stuck_out_tongue_winking_eye:

well, no. AFAIK you can’t run Arduino sketches on raspberry hardware directly.
Sorry, I have misunderstood the way you lost your main.cpp file.

So everytime when I want to run a blynk project/example I’ve to edit main.cpp file, then build and connect it to my blynk app by the project’s token, right?

@fabianpi yes if you want to use C++ but Blynk also has the javascript (node) client.

@GunnerTechTools when you tested the C++ stuff on your Pi was it a Pi 3?

Wondered if you could test something for me if you have a Pi 3. Does the gpio pin still go high and low if you remove the button tied to the digital pin i.e. control just by the button tied to a virtual pin?

Works OK for my Pi Zero’s but not for @schmersgahoven’s Pi 3.

No fansnazzy new stuff for me, I am afraid… My RPi is one of the originals (RPi Model B ver 2.0). But so far all GPIO’s I have tested do what they should with either Virtual or Physical buttons in both C++ and Javascript clients.

1 Like

I’m about to order my first Pi or clone.

Should I just go for the Pi 3 and test this?

@Jamin I prefer the size and price of the Zero but it depends what plans you have for the Pi.

Plans = tinker