Connect the APC220 radio module and submit the data to Internet
From wikiluntti
Introduction
Theory
Connecting
Use 3.3V on do not use EN pin on APC220. Need to connect only Vin (3.3V), GND, RX and perhaps TX.
See the image on https://www.etechnophiles.com/raspberry-pi-1-gpio-pinout-schematic-and-specs-in-detail/
Pins (from Wikipedia)
GPIO# | 2nd func. | Pin# | Pin# | 2nd func. | GPIO# | |
---|---|---|---|---|---|---|
+3.3 V | 1 | 2 | +5 V | |||
2 | SDA1 (I2C) | 3 | 4 | +5 V | ||
3 | SCL1 (I2C) | 5 | 6 | GND | ||
4 | GCLK | 7 | 8 | TXD0 (UART) | 14 | |
GND | 9 | 10 | RXD0 (UART) | 15 | ||
17 | GEN0 | 11 | 12 | GEN1 | 18 | |
27 | GEN2 | 13 | 14 | GND | ||
22 | GEN3 | 15 | 16 | GEN4 | 23 | |
+3.3 V | 17 | 18 | GEN5 | 24 | ||
10 | MOSI (SPI) | 19 | 20 | GND | ||
9 | MISO (SPI) | 21 | 22 | GEN6 | 25 | |
11 | SCLK (SPI) | 23 | 24 | CE0_N (SPI) | 8 | |
GND | 25 | 26 | CE1_N (SPI) | 7 |
Coding
- HDMI console
- Serial console via UART cable
Uart: Universal Asynchronous Receiver-Transmitter.
Enable UART using raspi-config or using /boot/config.txt: Is is better to disable serial console in raspi-config??
- 3 Interface Options -> P6 Serial port; OR
- Advanced options -> Serial -> Yes, reboot.
Enable UART:
The serial login shell is disabled The serial interface is enabled
/boot/config.txt
add line
enable_uart=1
Reboot.
dmesg | grep tty
Set the Baud rate to 9600 bps.
cat /dev/serial0
The UART device on the Pi is /dev/ttyAMA0.
python3 -m serial.tools.miniterm /dev/serial0 9600
#!/usr/bin/env python import time import serial ser = serial.Serial( port='/dev/ttyUSB0', baudrate = 9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) while True: x=ser.readline() print x,
sudo python serial_read.py
Use UART using Python.
References
- https://stackoverflow.com/questions/28528072/how-to-use-apc220-radio-communication-module-in-raspberry-pi
- https://forums.raspberrypi.com//viewtopic.php?t=16280
- https://pimylifeup.com/raspberry-pi-serial/
- https://digitalshack.org/raspberry-pi-uart-tutorial/
- https://www.instructables.com/Connect-the-Raspberry-Pi-to-network-using-UART/