Calling Additional Scripts from Arduino-Cli when uploading to a board - python

I have a Raspberry Pi connected to an Arduino Mini that it normally communicates with over I2C. But I'd also like to be able to reflash the Mini with new code using Arduino-Cli from the Raspberry Pi (kinda rhymes!). This would involve connecting the Raspberry Pi's GPIO serial port to the Arduino's serial port. Additionally, the Arduino Mini requires a manual reset to be applied before its code can be reflashed, which is something the Raspberry Pi can do by toggling a GPIO pin attached to the Mini's reset line. I can do this with a simple Python script. The question is: is there a way for Arduino-Cli to call additional scripts as part of the upload command?

Related

Remote GPIO (Pigpio) with input from laptop and output from Raspberry Pi

I'm working on an object detection project for IoT using a webcam and servo. In short, when the object detected by the webcam matches the data in the system, the servo will move. Can the webcam be connected to the laptop, and the servo on the Raspberry Pi? So the input is from the laptop and the output is on the Raspberry Pi using pi-gpio (Remote GPIO). How to? Thanks.
This link shows the GPIO Zero library being used with pigpio to allow remote control of the GPIO pins, from either another raspberry pi - or a PC. Once you configure GPIO Zero to use the pigpio library and connect, I believe you can just use the GPIO Zero libraries as per normal to control the Servo. (though I have not tried this myself!)
However I would probably use MQTT to decouple the two systems. If you run an MQTT broker on the Raspberry Pi (eg. Mosquitto) then the webcam software can publish a message to the MQTT broker, and the raspberry pi software can subscribe and act accordingly.
You can also run this with a cloud based MQTT system (eg. HiveMQ) so the Raspberry Pi and the PC with the Webcam don't even have to be in the same location.
A quick way is to use the Python socket library. Both devices need to be connected to the same network, and the sender needs to know the IP address of the receiver.

Send Sensor Data & Stream Video Over Bluetooth (Raspberry Pi to PC)

I would like to send sensor data (string) and live video from the Raspberry Pi camera over Bluetooth. I would like to do this with python. I would like to display the video on the PC in a tkinter window. Any ideas??
Raspberry Pi: Pi 3
PC: Windows 10 with Python 3.8.3 64 bit
Video might be a bit tricky. More details at: https://stackoverflow.com/a/64062680/7721752
Bluetooth on Windows with Python is not that well supported. However, with Python 3.9 there is support for Serial Port Profile (SPP). There is details of how to create the client at: https://stackoverflow.com/a/62815818/7721752
To create the Server on the Raspberry Pi (RPi) I would use the Bluedot library:
https://bluedot.readthedocs.io/en/latest/btcommapi.html#bluetoothserver
(Bluedot only works on RPi)
Developing both ends of a Bluetooth link at the same time is tricky if you are new to creating Bluetooth. My suggestion would be to create the Server on the RPi first and use an app like Serial Bluetooth Terminal on your phone to test it. Once that is working start on developing the client.

connect two raspberry pi call python function

I have two raspberry pi's connected to a hub
One is the server and one is the client. what i want to do is run 2 python scripts on both raspberry pi's
Then call function on each raspberry so the server needs to call functions in the script that is running on the client and vice versa
But how can i do that because i dont really understand socket communication
I had a bit of code that worked but i needed the IP of both raspberry's all the time.
So hope someone can help so i can call functions on other raspberry pi's

Use uart on Raspberry Pi usb port with Python

im working on a project to connect a Pic to a Raspberry pi via uart.
I know they both have uart pins, but I need to connect them via usb, the cable also serves as the power supply for the Pic.
So my question is, is it possible to use python, C# might also be an option with mono, to use an USB port on the Raspberry Pi for UART?
this is a tutorial I found about uart on the Raspberry Pi with Python
a turorial on what is uart
Not possible.
USB uses two 'pins' for transmission using 'differential signaling'.
This means, both pins are used for sending and transmission.
In UART you use one pin for transmission and one for reception.
Without any interface, not possible.

running a python script when both bluetooth devices gets paired in raspberry PI

I have a project where I have to send data acquired from an accelerometer through a Bluetooth module connected to my pi to a smart phone. A python script will be designed to acquire and send the data to the UART of the raspberry pi. I want to run my script when the Bluetooth of my smart phone and Bluetooth module connected to the pi gets paired. Is that possible?

Categories