How to stream data from MPU6050+NodeMCU to Raspberry Pi? - nodemcu

I'm working on a small project, trying to wirelessly stream Accelerometer and Gyro data from 5 MPU6050 to my Raspberry pi at 100Hz via wifi. I've managed to configure the NodeMCUs to sample the data from my accelerometers, but now I'm a little confused with how to get that data over to Pi.
Ideally, I want to have something similar to a "Serial Monitor" seen in the Arduino environment but instead on my Pi terminal window. As far as I understand, I need to set-up a "SERVER" on my pi and then connect NodeMCUs to it as "CLIENTs" (I've found this library: https://github.com/ekstrand/ESP8266wifi.
Does this make sense? If so, can someone point me in a "getting started" guide on how to set-up a server like that on Pi 3B?

Try this create a python script that will hit the web service where web service is the ip address of your nodemcu and from nodemcu send a JSON response parse the JSON response in your python script and display it.

Related

FiPy gateway not receiving uplinks from Raspberry Pi Pico with sx1262 module LoRa node

I'm trying a setup for LoRa with a FiPy board as a gateway/forwarder and a Raspberry Pi Pico with the Waveshare sx1262-686m hat for LoRa.
The FiPy is listening on the 868.1 Mhz frequency (EU868) and it works fine with a Lopy class C node that joins with ABP. The node is forced to send its uplink packets on the 868.1 MHz frequency. It's not able to receive downlinks but it is fine for now.
These are the logs shown by the gateway when communicating with the Lopy:
txpk is packets coming from the Chirpsack network server while rxpk is uplinks coming from the node.
Then I tried to make the Pico communicate with the FiPy, using the lorawan library for pico developed by Waveshare for their hat.
The problem I'm facing is that the pico node seems to be sending out the uplink packets but the FiPy forwarder doesn't receive them. From the node logs it seems like it is sending out data just fine but nothing appears on the gateway. The module is of course switched on and the antenna is connected.
After using the LoPy-FiPy setup, I thought that the problem was in the frequencies used by the node that was sending data on the other frequencies, so I changed the RegionEU868.h file to force every channel on the 868.1 Mhz and use only the 3 default channels. But even though in the logs it is shown that the frequency is the desired one, the gateway still receives nothing.
I'm now trying to use a proper Kerlink gateway but if anyone knows where the problem lies (if any) help is appreciated.
EDIT: with the Kerlink gateway everything works fine, so if anyone knows a workaround for the FiPy it'll be appreciated.
I forgot that other than forcing the frequency there's the need to force the SF and the DR to the one that the gateway is listening to. So since the gateway is configured for SF7BW125 I changed the RegionEU868.h file so that every DATARATE variable is set to DR_5,that is SF7BW125.
It works as a temporary solution. I will now procede to create dedicated functions to change those values instead of hardcoding them.

How to read files from a SD card connected to ESP32 an then transfer/upload/send them with Micropython to Raspberry Pi?

I am working on a project, basically my proposal consist in a solution designed under server/client paradigm, on host side I have mounted an Ubuntu Server 20.4 LTS (64 Bits) on a raspberry pi and setup Flask (1.1.1) as a restful web service, on the other side I have the ESP32 with Micropython (v1.19.1) as a client that is sending data thru http to the web API.
So far so good, but I am planning on keeping log files as back up on the SD card connected to ESP32 for down time communication scenarios between server and client, since the down time period could be from a few hours to a whole day, I was thinking on keeping data in raw format in files generated by the hour in text plain, then eventually whenever the connection gets stablished the ESP32 can send files to server, so data can be parsed and do whatever was missing on the flow.
I also know that I could do the data parsing on client side and send a bunch of request to the Web API but giving the condition that the down time can last for several hours this could affect the performance of the main task on the ESP32 which is to collect data from sensors and prepare it to be sent to the raspberry pi.
What have I tried so far?, well I already have the code to read files from a SD card with ESP32 but due to the constraints on Micropython I am not able to send them thru http since the urequests library does not support it, despite that Flask on server side can handle it without problem.
import urequests
from machine import Pin, SPI
import machine, sdcard, os
spi = SPI(1, baudrate=10000000, polarity=0, phase=0,
miso=Pin(13),
mosi=Pin(12),
sck=Pin(14))
sd = sdcard.SDCard(spi, Pin(27))
os.mount(sd, '/sd')
files = [
('20220510_08', open('/sd/20220510/20220510_08.csv','csv')),
('20220510_09', open('/sd/20220510/20220510_09.csv','csv'))
]
payload = {}
headers = {'Content-Type': 'multipart/form-data'}
host = "http://192.168.0.25:5000/uploadLogFile"
response = urequests.request("POST",url = host, headers=headers,files = files)
TypeError: unexpected keyword argument 'files'
I was also thinking on setting up the FTP service on the raspberry pi, and look for a FTP client for the ESP32 in Micropython, so files can be transfer.
I think in theory makes sense but I wonder if anyone else has made something similar and have a code sample to share or either if someone has any better recommendation, since I am still new to Micropython programming I might be missing sight of something else worth of reviewing .
I thank you all in advance.
Regards

using joystick on one raspberry pi to control input on second raspberry pi

I have a raspberry pi 4(let's call it server) that's operating servos and motors on a boat. I've managed to control the boat using another raspberry pi 4( let's call it client) and connect via SSH. First remote control was via touchscreen and gui that ended up pretty useless. I wanna try control by joystick which I've placed on client side. My problem is how do I implement the signal from joystick that I get from script on client as input signal on server side? Is there a way to do that via SSH or something else? In longterm there will be a camera, radar and sensors placed on the boat. Is the websocket best solution for that type of remote control?
Personally, I think I'd set up MQTT for this which is ideal for transferring short messages and doesn't require absolute "lock-step" communication back and forth. That means you can start in any order and the second half doesn't need to necessarily be present.
I'd install mosquitto on either RasPi, and then:
let RasPi with devices attached subscribe to a "joystick" topic so it gets all joystick movements, and
let RasPi with joystick attached publish each movement on that topic.
Enter [mqtt] in the StackOverflow search box for examples.
Alternatively, you could use Redis "pub/sub" just the same.
Enter [redis] in the StackOverflow search box for examples.

Is it possible to target a specific Arduino device with the CC3000 Wifi over the web?

I've got my CC3000 Wifi shield and Arduino Uno working as intended using the several libraries, including the aRest.h library. In order for me to control the Arduino from anywhere across the web, I configured the port-forwarding settings on the router to address the Arduino via the routers ip address.
My question is this: If I had a multiple Arduino modules/devices that relied on two way communication (client/server), how is the setup configuration automated for each device so that I could target a specific Arduino with regional data? I don't expect the end user to know how to access the router and configure port forwarding.
I hope this makes sense, I'm a newbie to the world of micro-controllers, but have had some success with progress as of late
You should be able to make a simple way to setup the Wifi, when this job is done you connect via socket so a socket server ( python,node,etc... ) and this will avoid any port-forwarding.
You will not need to care about all this messy tasks, you can have as many as you want arduino in the same network and access from the internet.

Connecting Arduino Uno with Ethernet shield to parse.com database

Hey I'm new to Arduino programming, I was wondering how i can connect my device to store data to parse.com.
I know the REST API Key but not sure one what to do. Any help would be appreciated, and if possible can you provide source code or examples.
Thanks!
This is now possible. An Arduino Uno + ethernet shied still can't make HTTP requests, and parse.com still needs HTTPs, but Temboo makes it possible. Here's what you need to do:
Create an account at Temboo.com
Go to the Parse bundle
Find the Choreo you're interested in e.g., UploadFile, and test it out from the Temboo website
Turn on IoT Mode, set up your shield, and use the generated Arduino sketch code to connect your board to Parse.
Here's a blog post about Temboo's Iot Mode - the feature makes all of this possible:
http://blog.temboo.com/post/88573872731/flip-the-switch-and-get-going
I hope this helps.

Resources