Using C++ on a Raspberry Pi with Blynk

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 …

http://serverfault.com/questions/166383/how-set-path-for-all-users-in-debian 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 - #44 by Costas 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 library.properties 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.

@Gunner 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

Well the 3 would be good for me as I’m terrible with a soldering iron as the Zero’s don’t have any headers.
For the Zero as a Blynk server it doesn’t need any headers but when you move on to client stuff it generally needs headers.

I have thought about buying some of these https://shop.pimoroni.com/products/gpio-hammer-header
With the jig you basically smack the headers on to the Zero with a hammer.

SimpleTimer should now be available, from the Master branch, for the Pi as @vshymanskyy pushed an update a few days ago. Intervals should be set at > 10ms.

2 Likes

This tutorial should be included as a reference in the help center raspberry pi setup guide.

1 Like