(2)-Temperature measurement data transfer WizFi360-EVB-Mini (Raspberry Pi Pico) – Client(Python)

Temperature measurement data transfer WizFi360-EVB-Mini (Raspberry Pi Pico) - Client(Python)
ORIGINAL POST
By Louis_m
components
details

KakaoTalk_20210616_161856982.jpg

WizFi360 is a low cost and low-power consumption industrial-grade WiFi module. It is compatible with IEEE802.11 b/g/n standard and supports SoftAP, Station and SoftAP+Station modes. The serial port baud rate can be up to 2Mbps.

WizFi360-PA(PCB Antena)

Instructions

img

img

WizFi360_TCP_Client

MicroPython Thonny IDE installation

  • MicroPython Thonny IDE Install

https://thonny.org/

  • Download Thonny and set it up for your Raspberry Pi Pico board.

img

  • Tools -> Options -> Interpreter

  • Set Raspberry Pi Pico and COMx in options

img

img

img

 

WizFi360 can be designed with a very simple circuit and data transmission is possible using UART1.

WizFi360 controls AT commands via UART and uses UART0 when Micro USB is connected.

WizFi360-EVB-Mini connection diagram

img

img

WizFi360 UART + AT command set

AT+CWJAP_CUR=”SSID”,”PASSWORD

Enter the SSID and PW of the AP (Router) you want to connect to.

AT+CIPSTART=0,”TCP”,”YOUR_IP_ADDRESS”,5000

Input Server’s IP in YOUR_IP_ADDRESS.

WizFi360_AT_Client.py


import os, sys
import utime
from machine import UART,Pin

print(os.uname())

#LED
led = machine.Pin(25, machine.Pin.OUT)
led.value(0)
utime.sleep(0.5)
led.value(1)

#Temperature
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

#Uart
#uart = machine.UART(0, baudrate=115200, tx=Pin(0), rx=Pin(1))
uart = machine.UART(1, baudrate=115200, tx=Pin(8), rx=Pin(9))
print(“UART Setting…”)
print(uart)

#Functions
def sendCMD_waitResp(cmd, timeout=3000):
print(“CMD: ” + cmd)
uart.write(cmd.encode(‘utf-8’))
waitResp(timeout)
print()

def waitResp(timeout):
prvMills = utime.ticks_ms()
resp = b””
while (utime.ticks_ms()-prvMills) < timeout:
if uart.any():
resp = b””.join([resp, uart.read(1)])
print(resp)

#AT command Test
sendCMD_waitResp(“ATrn”) #AT
sendCMD_waitResp(“AT+GMRrn”) #firmware ver

utime.sleep(0.5)
sendCMD_waitResp(“AT+RSTrn”) #reset
sendCMD_waitResp(“AT+CWMODE_CUR=1rn”) # Station Mode
sendCMD_waitResp(“AT+CWDHCP_CUR=1,1rn”) #DHCP

utime.sleep(0.5)
sendCMD_waitResp(‘AT+CWJAP_CUR=”SSID”,”PASSWORD”rn’) #AP connecting
sendCMD_waitResp(“AT+CIPSTA_CUR?rn”) #network chk

#TCP Client
sendCMD_waitResp(“AT+CIPMUX=1rn”)
sendCMD_waitResp(‘AT+CIPSTART=1, “TCP”,”192.168.1.100″,5000rn’)

print(“connected…”)
print(“RPi-PICO with WizFi360”)

Data = bytes()

while True:
reading = sensor_temp.read_u16() * conversion_factor
temperature = 27 – (reading – 0.706)/0.001721
print(temperature)
temp = str(temperature)
utime.sleep(1)
sendCMD_waitResp(“AT+CIPSENDBUF=1,20rn”)
sendCMD_waitResp(“Temperature: “)
send = uart.write(temp.encode(‘utf-8’))


Transmit temperature measurement data from Client to Server.

Since Pico has a built-in temperature sensor, there is no need to use another one.

Temperature data to Server

img

Temperature data from Client

img

Thank you.

KakaoTalk_20210616_161856982.jpg

WizFi360 is a low cost and low-power consumption industrial-grade WiFi module. It is compatible with IEEE802.11 b/g/n standard and supports SoftAP, Station and SoftAP+Station modes. The serial port baud rate can be up to 2Mbps.

WizFi360-PA(PCB Antena)

Instructions

img

img

WizFi360_TCP_Client

MicroPython Thonny IDE installation

  • MicroPython Thonny IDE Install

https://thonny.org/

  • Download Thonny and set it up for your Raspberry Pi Pico board.

img

  • Tools -> Options -> Interpreter

  • Set Raspberry Pi Pico and COMx in options

img

img

img

 

WizFi360 can be designed with a very simple circuit and data transmission is possible using UART1.

WizFi360 controls AT commands via UART and uses UART0 when Micro USB is connected.

WizFi360-EVB-Mini connection diagram

img

img

WizFi360 UART + AT command set

AT+CWJAP_CUR=”SSID”,”PASSWORD

Enter the SSID and PW of the AP (Router) you want to connect to.

AT+CIPSTART=0,”TCP”,”YOUR_IP_ADDRESS”,5000

Input Server’s IP in YOUR_IP_ADDRESS.

WizFi360_AT_Client.py


import os, sys
import utime
from machine import UART,Pin

print(os.uname())

#LED
led = machine.Pin(25, machine.Pin.OUT)
led.value(0)
utime.sleep(0.5)
led.value(1)

#Temperature
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

#Uart
#uart = machine.UART(0, baudrate=115200, tx=Pin(0), rx=Pin(1))
uart = machine.UART(1, baudrate=115200, tx=Pin(8), rx=Pin(9))
print(“UART Setting…”)
print(uart)

#Functions
def sendCMD_waitResp(cmd, timeout=3000):
print(“CMD: ” + cmd)
uart.write(cmd.encode(‘utf-8’))
waitResp(timeout)
print()

def waitResp(timeout):
prvMills = utime.ticks_ms()
resp = b””
while (utime.ticks_ms()-prvMills) < timeout:
if uart.any():
resp = b””.join([resp, uart.read(1)])
print(resp)

#AT command Test
sendCMD_waitResp(“ATrn”) #AT
sendCMD_waitResp(“AT+GMRrn”) #firmware ver

utime.sleep(0.5)
sendCMD_waitResp(“AT+RSTrn”) #reset
sendCMD_waitResp(“AT+CWMODE_CUR=1rn”) # Station Mode
sendCMD_waitResp(“AT+CWDHCP_CUR=1,1rn”) #DHCP

utime.sleep(0.5)
sendCMD_waitResp(‘AT+CWJAP_CUR=”SSID”,”PASSWORD”rn’) #AP connecting
sendCMD_waitResp(“AT+CIPSTA_CUR?rn”) #network chk

#TCP Client
sendCMD_waitResp(“AT+CIPMUX=1rn”)
sendCMD_waitResp(‘AT+CIPSTART=1, “TCP”,”192.168.1.100″,5000rn’)

print(“connected…”)
print(“RPi-PICO with WizFi360”)

Data = bytes()

while True:
reading = sensor_temp.read_u16() * conversion_factor
temperature = 27 – (reading – 0.706)/0.001721
print(temperature)
temp = str(temperature)
utime.sleep(1)
sendCMD_waitResp(“AT+CIPSENDBUF=1,20rn”)
sendCMD_waitResp(“Temperature: “)
send = uart.write(temp.encode(‘utf-8’))


Transmit temperature measurement data from Client to Server.

Since Pico has a built-in temperature sensor, there is no need to use another one.

Temperature data to Server

img

Temperature data from Client

img

Thank you.

documents
Code
WizFi360_AT_Client.py

COMMENTS

Please Login to comment
  Subscribe  
Notify of