Arduino / Raspberri communication with EG

If you have a question or need help, this is the place to be.
Post Reply
User avatar
Medy
Experienced User
Posts: 153
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Arduino / Raspberri communication with EG

Post by Medy » Thu Aug 06, 2020 7:04 pm

Im currently looking into building some Internet of things devices...
- Looking at Arduino (for creating some battery driven gadgets with led / epaper display)
that run a script hourly and then go into sleep mode


Anyone experience on how to best send messages to arduino via eg ?
Im total newb ... and just about to purchase a esp8266 or maybe esp32

Just thought someone here might know smth :D...


If not its ok


Cheers

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Arduino / Raspberri communication with EG

Post by kgschlosser » Fri Aug 07, 2020 2:54 am

You are going to want to run an Arduino Mega 2560 at a minimum. Also using an Arduino as a battery powered device I do not think would work well given the size of the battery you would need to run it for sustained periods of time.

That being said. To send/receive you will need this plugin installed into EG.
https://github.com/per1234/TCPEvents

And you will need to use this library on the Arduino
https://github.com/per1234/EtherEvent

If you are a n00b it is going to take you some time to learn how to get everything working. There is no simple interface for the Srduino. You are going to have to write the firmware for it and flash it. You are going to need to learn c/c++ if you do not already know the language.

As an alternative you may want to use the ESP32 micro controller instead of the Arduino. It can do just about everything an Arduino is able to do except it is vastly faster, has multiple cores which means you have the ability to use threads. It has more memory. It also has WiFi and Blueteeth built into it. This device CAN be run off a battery. You can also run Python on it as well making it far easier to write programs for. You can also get them for a fraction of the price that an Arduino costs. typically between 5.00USD and 10.00USD depending on where you purchase them. Just make sure you get the ones that are the "development boards" and not just the chip.

I would recommend looking into the ESP32's they are far easier to deal with and there is a heap of available web GUI's that you can flash to them to assist loading the thing with the software you want to be able to address whatever sensors you have plugged into it.
If you like the work I have been doing then feel free to Image

User avatar
Sem;colon
Plugin Developer
Posts: 730
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Arduino / Raspberri communication with EG

Post by Sem;colon » Fri Aug 07, 2020 7:03 pm

For communication with an raspberry you can use the EG SSH plugin.
Works pretty much out of the box, you just need to enable the SSH interface on the pi.
viewtopic.php?f=9&t=6021
If you like my work, Image me a drink :wink:

User avatar
Medy
Experienced User
Posts: 153
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Re: Arduino / Raspberri communication with EG

Post by Medy » Sat Aug 08, 2020 7:30 pm

Thx for your replies ... I reasearched for a while and found
the m5stack device line .

What is m5stack video :
https://www.youtube.com/watch?v=cQWkIHxQoCY


I think this will be perfect ... so I ordered the core model from amazon ...
Im going to learn some C basics ... and maybe lokking into the "micropython language" which is availabe for this kit...

not goign for battery powered for starters (there are battery stacks you can add ... but only small ones)... but I will probably use the esp32 chip to DIY some stuff that is battery powered with larger batteries.... im interested in epaper displays for low power consumption....


Image

This m5stack line has some cool models:

m5stack core
m5stickC
m5atom matrix
m5atom


also tons of plug and play modules you can add to it..
https://m5stack.com/collections/m5-hat


Think this is going to be fun to play with... and beginner friendly



the esp32 chip will serve me well probably ...

User avatar
Medy
Experienced User
Posts: 153
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Re: Arduino / Raspberri communication with EG

Post by Medy » Sun Aug 23, 2020 2:38 pm

kgschlosser wrote:
Fri Aug 07, 2020 2:54 am
You are going to want to run an Arduino Mega 2560 at a minimum. Also using an Arduino as a battery powered device I do not think would work well given the size of the battery you would need to run it for sustained periods of time.

That being said. To send/receive you will need this plugin installed into EG.
https://github.com/per1234/TCPEvents

And you will need to use this library on the Arduino
https://github.com/per1234/EtherEvent

If you are a n00b it is going to take you some time to learn how to get everything working. There is no simple interface for the Srduino. You are going to have to write the firmware for it and flash it. You are going to need to learn c/c++ if you do not already know the language.

As an alternative you may want to use the ESP32 micro controller instead of the Arduino. It can do just about everything an Arduino is able to do except it is vastly faster, has multiple cores which means you have the ability to use threads. It has more memory. It also has WiFi and Blueteeth built into it. This device CAN be run off a battery. You can also run Python on it as well making it far easier to write programs for. You can also get them for a fraction of the price that an Arduino costs. typically between 5.00USD and 10.00USD depending on where you purchase them. Just make sure you get the ones that are the "development boards" and not just the chip.

I would recommend looking into the ESP32's they are far easier to deal with and there is a heap of available web GUI's that you can flash to them to assist loading the thing with the software you want to be able to address whatever sensors you have plugged into it.

Would the libraraies work on a esp 32 ? the m5stack device has a esp32 built in.

Also it seems that the m5devices have some support for mqtt ... would that work with eventghost ?

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Arduino / Raspberri communication with EG

Post by kgschlosser » Tue Aug 25, 2020 9:03 am

There is an MQTT plugin for EventGhost. IDK if you are familiar with MQTT or not. It is really geared at the "technical" user. so keep that in mind.

Now that device you have is going to have firmware on it that would have to be altered in order to add anything to it. You would need to have access to the source code of the firmware (open source) and also be able to put the device into a mode where it can be flashed. If you do not have those 2 things then adding to it is not going to happen and MQTT is the only option you are going to have.

Let me do some research on the device and see what I come up with.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Arduino / Raspberri communication with EG

Post by kgschlosser » Tue Aug 25, 2020 9:14 am

OK so you are in luck!!

the firmware is open source and the thing is able to be flashed. and as it would happen it can be flashed using the Arduino IDE.

https://github.com/m5stack/M5Stack

I just dropped a line to the author of EtherEvent (friend of mine)to see if he would be willing to add ESP32 support to his library. If he is willing and once he makes the changes I can add it to the firmware and you can then flash it to the device.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Arduino / Raspberri communication with EG

Post by kgschlosser » Tue Aug 25, 2020 9:31 am

as it turns out the thing also runs MicroPython and has an API for it.

https://github.com/m5stack/UIFlow-Code

so I do not need to bother with EtherEvents at all. You need to know how to write Python code to get the thing to do what you want it to do. I can help you with the connection to EventGhost portion of the code.
If you like the work I have been doing then feel free to Image

User avatar
Medy
Experienced User
Posts: 153
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Re: Arduino / Raspberri communication with EG

Post by Medy » Wed Aug 26, 2020 8:13 pm

kgschlosser wrote:
Tue Aug 25, 2020 9:31 am
as it turns out the thing also runs MicroPython and has an API for it.

https://github.com/m5stack/UIFlow-Code

so I do not need to bother with EtherEvents at all. You need to know how to write Python code to get the thing to do what you want it to do. I can help you with the connection to EventGhost portion of the code.

Yes I need a connection ... easy lightweight if possible ... SO far I was reading up on mqttt

I figured it is kind of overkill... and the concept of having a broker device running is kinda annoying ...
I could probably pull off mqtt now having learned about it --- installing a broker like mosquito on my pc and have the other devices connect to it...should be easy ... since the UI flow also has some mqtt ready to go blocks

But I would love not to go the mqtt route

The m5stack is a real nifty device and will go really nice together with eventghost.

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Arduino / Raspberri communication with EG

Post by kgschlosser » Wed Aug 26, 2020 9:18 pm

do you know how to program in Python? This is what you are going to need to do in order to write a UI for the thing. Tho there is a UI framework I am sure that is apart of the SDK. But you are not limited to only using the framework from m5stack. You can use any number of GUI frameworks that are available for MicroPython. Writing a socket connector to talk directly to EG without the need to use MQTT. I would want to write a specific plugin for this device as well that would broadcast a packet for auto discovery (user would turn this on). By doing that there would be no need to make a GUI interface on the dveice to set the thing up. It would do it all automatically.
If you like the work I have been doing then feel free to Image

User avatar
Medy
Experienced User
Posts: 153
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Re: Arduino / Raspberri communication with EG

Post by Medy » Thu Aug 27, 2020 12:12 pm

I know basic python ... like the very basics of the language ...

UIflows comes with Blockly , so I can drag and drop text onto the screen .. or write the same stuff in micropython... you can switch back and forth between these 2 modes

Image

Havent really though about using another GUI library for the m5 devices ... but I like the idea since there would be more options to play with probably


If we are using sockets I already have a idea how this is going to work.

If you remember you helped me with a plugin a while back which also used sockets.... you gave me
the basic socket code I needed for connecting a chrome extension to eventghost via websocket. (which we turned into a extension for (Google Chrome .. to interact with browser tabs)) ...
I handled the Wxpython stuff and the javascript part there.


So I imagine this will be similiar. on the eg side of things ...


Adding auto discovery and auto connect for multiple devices that would be great.
I have these devices:
-2 m5tasck core
-2 m5atoms matrix (no screen , just 25 individual leds)

which I would like to hook up at once and send messages to individually via eventghost ...
These devices also have buttons so I guess can be used to send stuff back to eventghost as well


There also sleep modes since the m5devices using a eps32 chip .... maybe can add some actions to trigger those... just some idea :D

So I need :
----------
Eventghost Plugin:
- websocket server


M5device :
- auto discover eventghost and connect via websocket

m5 Eventghost Mode Program Pseudo Code :
1. Connect to Wifi
2. Connect to Eg via Socket (loop)
3. Recieve Commands from EG
4. Execute pre defined commands

User avatar
Medy
Experienced User
Posts: 153
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Re: Arduino / Raspberri communication with EG

Post by Medy » Sun Sep 20, 2020 3:27 pm

kgschlosser wrote:
Wed Aug 26, 2020 9:18 pm
do you know how to program in Python? This is what you are going to need to do in order to write a UI for the thing. Tho there is a UI framework I am sure that is apart of the SDK. But you are not limited to only using the framework from m5stack. You can use any number of GUI frameworks that are available for MicroPython. Writing a socket connector to talk directly to EG without the need to use MQTT. I would want to write a specific plugin for this device as well that would broadcast a packet for auto discovery (user would turn this on). By doing that there would be no need to make a GUI interface on the dveice to set the thing up. It would do it all automatically.

I was thinking of how to display the data today ...
and made a couple of mokups for presets I want to be available for a plugin user to choose from.

The data would come from eventghost ... just simple datasets ... and maybe a little bit of customisation option on some tempates ... maybe not

Basicly sending a json to the device with
{
preset : 1
action : create
title: title
Message: text
}

{
preset : 1
action : update
title: newtitle
}

and then disoplay some stuff like this...

Image

This little ones are quite feature packed for just 13 bucks
they have a built in extra led ... a buzzer .. and axis sensor

Image

1. The device would recieve the json we send it from eventghost
2. load the data into its presets

thats how I would like to start with it ...

I guess users could create their own presets for their devices ...
so maybe I could add a custom plugin funciton action that lets you send your own json to the device.

I think thats how ill do it ;D

Post Reply