0

Is it possible to run C/C++ commands directly using Johnny-F
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Is it possible to run C/C++ commands directly using Johnny-F

by Trillion on Wed Jun 05, 2019 8:47 pm

I've been working with Johnny-Five as way to get started working with and programming micro-controllers.
Benefits:
    Familiarity with JS over C/C++, Python, and NodeMCU
    The StandardFirmataWiFi + J5 makes it possible to control multiple controllers externally from a single central machine.

The benefits have been great.

Downsides:
    Limited support & community for J5
    Limited commands -- difficulty of finding JS equivalents to certain C/C++ commands

Question:
Is it possible to issue C/C+ (or even Python) commands from Johnny-Five? So in other words instead of the central machine issuing J5-only commands to the micro-controllers, you could, when necessary, send C/C++ command snippets. If so, that would make it easier to work directly with demo/community-shared code and make it easier for JS-fluent developers to transition toward C.

Trillion
 
Posts: 46
Joined: Tue Apr 23, 2019 11:20 pm

Re: Is it possible to run C/C++ commands directly using John

by adafruit_support_mike on Thu Jun 06, 2019 1:02 am

I’m afraid we don’t have any in-house experts in Johnny-Five. Your best bet would be to contact the folks responsible for that framework and see what information they have.

adafruit_support_mike
 
Posts: 58799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Is it possible to run C/C++ commands directly using John

by Trillion on Thu Jun 06, 2019 10:58 pm

adafruit_support_mike wrote:I’m afraid we don’t have any in-house experts in Johnny-Five. Your best bet would be to contact the folks responsible for that framework and see what information they have.


No doubt. Had done. Response times are slow to none, hence the note about 'limited support'.

Maybe then the more appropriate question here in Adafruit land is this:
Controlling a series micro-controllers (in this case ESP8266s) via WiFi from a single central machine is proving to be a valuable approach to setting up elaborate IoT systems. (As opposed to running a series of autonomous micro-controllers.)

So far the only way I know how to do this is to flash each ESP with StandardFirmataWiFi and control them using J5 on the central machine. Is it possible to instead use C/C++ to run the controllers?

Trillion
 
Posts: 46
Joined: Tue Apr 23, 2019 11:20 pm

Re: Is it possible to run C/C++ commands directly using John

by adafruit_support_mike on Sun Jun 09, 2019 12:31 am

That sounds more like a matter of making multiple boards communicate with the same central node. There are lots of different ways to do that.

For starters, do you want to use a wired connection between the central device and the ESP8266s, or piggyback it onto the Wifi?

adafruit_support_mike
 
Posts: 58799
Joined: Thu Feb 11, 2010 2:51 pm

Re: Is it possible to run C/C++ commands directly using John

by Trillion on Sun Jun 09, 2019 2:04 pm

adafruit_support_mike wrote:That sounds more like a matter of making multiple boards communicate with the same central node. There are lots of different ways to do that.
For starters, do you want to use a wired connection between the central device and the ESP8266s, or piggyback it onto the Wifi?


So here's the configuration I'm currently working with:
There's a central machine running Node JS / J5. There are over 5 ESP8266s attached to various devices, each one flashed with StandardFirmataWiFi. From my perspective it's the central machine is controlling the ESPs via WiFi which in turn control whatever devices are wired to them. So far everything is working, using either an RPI or Mac Unix as the "central machine" (both are working fine) I'm controlling over 10 garden solenoids, several Adafruit thermometers, and some AC-Powered LED Light bulbs using.

Where I'm running into trouble is trying to learn AC Dimming and the challenge of handling zero-crossing.
As I'm understanding it, the zero-crossing requires a speed and precision responsiveness that would lost on a round trip over WiFi communication between the ESP and the central machine.

Since last posting I finally started working with some C/C++ directly on the ESP -- first time ever working with a compiled language, and it's working.

So the thought was to create a C/C++ function that handles the AC Dimming / z-c functionality directly on an ESP.
I'd like to able to communicate from J5 to the function -- sending, say, a timing message update (dim less dim more, i.e. J5 updates a variable in the C/C++ function)

So maybe the question is: is it possible to create a custom function, add it to the StandardFirmataWiFi, and communicate with that function via J5.
In the same way Browser JS sends a message via Ajax to some PHP back end -- JS doesn't write code, but rather just send message which the PHP back end interprets.
Can something similar be done between J5 and C/C++ on an Arduino board? Is there a way to have C/C++ on the ESP be listening for a message from J5 and respond dynamically to the message it receives?

Trillion
 
Posts: 46
Joined: Tue Apr 23, 2019 11:20 pm

Please be positive and constructive with your questions and comments.