From a5a279a64d9497b76b10d286c324f821e1ff5991 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Fri, 3 Aug 2018 22:44:01 +0200 Subject: [PATCH] Add first lines of code to send json data to raspberry pi with additionnal UART --- circuitpython/code/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/circuitpython/code/main.py b/circuitpython/code/main.py index fb6ef79..b6066dd 100644 --- a/circuitpython/code/main.py +++ b/circuitpython/code/main.py @@ -34,6 +34,7 @@ __version__ = 0.1 # config # ########## print_data = True +send_json_data = True backup_data = True data_to_neopixel = True gps_enable = True @@ -262,6 +263,11 @@ if gps_enable: gps.send_command('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') gps.send_command('PMTK220,1000') # 1000 ms refresh rate +# second UART to communicate with raspberry pi GPIO +if send_json_data: + rpi_uart = UART(microcontroller.pin.PB10, microcontroller.pin.PB11, + baudrate=115200, timeout=2000) + # Integrated Neopixel if data_to_neopixel: pixel = neopixel.NeoPixel(microcontroller.pin.PA06, 1, brightness=1) @@ -292,7 +298,8 @@ while True: data.update() if print_data: data.show() - print(data.json()) + if send_json_data: + rpi_uart.write(data.json()) if backup_data: data.write_on_flash() if data_to_neopixel: