Menu

Super Simplfied WIFI example/working code (WizFi360)

Christos
2021-08-28
2021-08-28
  • Christos

    Christos - 2021-08-28

    From time to time there are questions about how to use wifi.
    Recently i found WizFi360, from Wiznet. https://www.wiznet.io/product-item/wizfi360/
    it is very similar to ESP8266 in shape - firmware - cost

    as said "searching too long to find something to fit our need simple and cheap" Wink

    I have come across to use the ESP8266 many times, but the overloaded information lack (until recently) to proper english documentation from manufacturer etc, i had confused.
    In contrary wiznet products are easy to get in europe/usa , as it is available in most big European warehouses
    at the time of writing WizFi360 cost 2,99€ .. And have good english documentation

    In the Simplest form i will present you, we will use device's own SoftAP/webserver to configure SSID,
    which makes compatible with any mobile OS and any laptop out there.
    Additionally removes "code space" and complex from our mcu code.

    The following program is supersimplified, among other it does not check for anything, but i have a working WIFI program in 992 bytes in one of the older AVR (90S2313) out there, and have room for more code !

    How Sample Program Works

    1) The program set's WizFi360 in SoftAP mode and initiates WebServer, if during power up you have press PB.0 to GND
    2) After this step you connect to Device SoftAP using mobile phone/laptop and open a browser http://192.168.36.1
    you will see a image as in the attachemnt file to set SSID / password and press save
    ** note that most android phones MUST wait to popup a message "this network has no internet remain ?" and click YES

    3) Start a Server listening to Port 5000 in a server at 192.168.1.10 (as this is in example program)
    4) power device again

    5) sending 1 to 3 will toggle PD4/5/6, sending 4 will return PORTB status in ascii
    so this example program is actually 8 button status check, and 3 led control from other side of lan

    Wiring
    only connect 3.3 volt to avr + wifi and uart1 of WizFi360 to AVR uart

    Sample Program Code

      #chip 90s2313, 3.6864
    
      'USART settings
      #define USART_BAUD_RATE 115200  'Initializes USART port with 9600 baud
      #define USART_TX_BLOCKING
      #define USART_DELAY OFF
    
      dim inchar as byte
      dim portstatus as string
      'Set PORTB to input
      Dir PORTB In
      PORTB = 255 ' Pull ups
      'set Port d4-6 out
      Dir PORTd b'11110000'
    
      wait 2 s
      if PINB.0 =0 then
       HSerPrintStringCRLF "AT+RESTORE=1"
       wait 1 s
       HSerPrintStringCRLF "AT+CWMODE_CUR=2"
       wait 1 s
       HSerPrintStringCRLF "AT+WIZ_NETCONFIG"
       wait 1 s
      do
      loop ; halt execution
      end if
    ' START A SOCKET CONNECTION
      HSerPrintStringCRLF "AT+CIPSTART=""TCP"",""192.168.1.10"",5000"
      wait 1 s
      HSerPrintStringCRLF "AT+CIPMODE=1"          ' change to singe connection mode
      wait 1 s
      HSerPrintStringCRLF "AT+CIPSEND"
      wait 1 s
      HserPrintCRLF                          ' immediatly send "return" means enter transparent mode
    
    ' Start a Program just like use a "true serial"
    ' "program" is send ascii 1 = togle pin PD4 2 = toggle PD5, 3 = Toglle PD6, 4 = return Portb status in ASCII
    
      Do
        InChar = HSerReceive
    
        Select case InChar
          case 49 ' ascii 1
            portd.4 = not portd.4
          case 50 ' ascii 2
            portd.5 = not portd.5
          case 51 ' ascii 3
            portd.6 = not portd.6
          case 52 ' ascii 4
            portstatus = bytetobin(PINB)
            HSerPrintStringCRLF portstatus
        end select
      Wait 1 s
      Loop
      `
    
     
  • Anobium

    Anobium - 2021-08-28

    Great insights. Thank you!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.