A topic of GPS IOT application for use with MicroPython and ESP8266 mini D1.Send the datas to the server and display it on the Google map.
- mini-mcu wifi board
- 11 digital I/O pins
- 1analog input
- 4 MB flash
- ssd1306 0.96 inch OLED display
- I2C driver
- UART TTL connector
- EEPROM to store settings
D1 mini | 6MV2 | DHT11 | OLED |
---|---|---|---|
3.3 |
VCC |
VCC |
VCC |
GND |
GND |
GND |
GND |
Rx |
Tx |
||
Tx |
Rx |
||
GPIO 4 |
Single |
||
SCL (GPIO 13 ) |
SCL |
||
SDA (GPIO 12 ) |
SDA |
https://github.com/DDPlay123/IoT_Python_Server
- Import webrepl_setup
- boot.py setting
- set your wifi's name and password in boot
- burn main.py into D1 mini
# Main function
gps = GPS()
oled = OLED()
#d = dht.DHT11(Pin(2))
def loop():
global gps, oled, api, d4
gpsStr = b''
gpsReading = False
while True:
data = gps.getGPSInfo()
#d.measure()
#if data and (gpsReading or ('$GNRMC' in data)) : #You need to check your GPS data is GPMRC or GNMRC
if data and (gpsReading or ('$GPRMC' in data)) :
gpsStr += data
if '\n' in data:
gpsReading = False
#temp = d.temperature()
#hum = d.humidity()
lat, long= gps.convertGPS(gpsStr)
oled.displayGPS(lat, long)
# Send lat&long to Web Server
value1 = '{"longitude":'+'"'+long+'"'+','
value2 = '"latitude":'+'"'+lat+'"'+','
#value3 = '"temp":'+'"'+str(temp)+'"'+','
#value4 = '"humid":'+'"'+str(hum)+'"}'
data = value1+value2#+value3+value4
r = requests.post(url,data=data,headers=header)
#############
gpsStr = b''
gc.collect() #clear memory
break
else:
gpsReading = True