Control Arduino from Raspberry Pi with pyFirmata

Requirements Raspberry Pi with Raspbian OS installed in it Arduino Uno or any other Arduino board Arduino USB cable LED   Installing PyFirmata in Arduino using Raspberry Pi To upload PyFirmata firmware in Arduino, we have to install Arduino IDE in Raspberry Pi. Follow these steps to install: Step 1:- Connect the Raspberry Pi to… Continue reading Control Arduino from Raspberry Pi with pyFirmata

Arduino and cpp files

You can create an Arduino project in which you have a main .ino file with setup() and loop(), but all the stuff in .h and .cpp files.

Raspberry: upload Arduino sketch from CLI

install these packages sudo apt-get install arduino-core arduino-mk Then add yourself to the dialout group to allow you to upload code to the Arduino board sudo usermod -a -G dialout pi (Change pi to be your username if different) Create Makefile ARDUINO_DIR = /usr/share/arduino BOARD_TAG = uno ARDUINO_PORT = /dev/ttyACM* ARDUINO_LIBS = include /usr/share/arduino/Arduino.mk to… Continue reading Raspberry: upload Arduino sketch from CLI

ESP8266 WiFi module

Link for add board manager http://arduino.esp8266.com/stable/package_esp8266com_index.json Erase the esp esptool.py erase_flash Code to flash AT firmware to ESP8266 (ESP8266_AT_Bin_V1.5.1) esptool.py –baud 115200 –port /dev/tty.wchusbserial1420 write_flash -fm dio -ff 40m -fs detect 0x00000 boot_v1.7.bin 0x01000 user1.1024.new.2.bin 0xfc000 esp_init_data_default.bin 0x7e000 blank.bin 0xfe000 blank.bin

L293D, H Bridge Arduino

L293D is a DC motor controller. Below Arduino code to use it. unsigned char table[128] = {0}; int motor1_A=6; int motor1_B=5; int motor1_Speed=3; void setup() { pinMode(motor1_A,OUTPUT); pinMode(motor1_B,OUTPUT); } void loop() { // motor1 for (int i=0; i<256; i+=1){ digitalWrite(motor1_A,HIGH); // A = HIGH and B = LOW means the motor will turn right digitalWrite(motor1_B,LOW);… Continue reading L293D, H Bridge Arduino

Arduino and Python

If you want to read Arduino serial from Python. Install pySerial: pip intall pyserial the code: import serial … print(‘# Arduino Reader – hackweb’) print(‘entering loop…’) ardu = serial.Serial(‘COM3’, 115200) time.sleep(2) while True: print(ardu.readline())