Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Super Simplfied WIFI example/working code (WizFi360)

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
plouf

Bascom Member



Joined: 19 Jan 2012
Posts: 40
Location: Athens,Greece

greece.gif
PostPosted: Sat Aug 28, 2021 3:27 pm    Post subject: Super Simplfied WIFI example/working code (WizFi360) Reply with quote

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 542 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 bellow to set SSID / password and press save


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
Code:
'Simplest Possible WizFi360 Example
' 542 bytes !!

$regfile = "attiny2313.dat"
$crystal = 3686400
$hwstack = 40
$swstack = 16
$framesize = 32

$baud = 115200
DDRB  = &B00000000         ' PortB = input
PORTB = &B11111111         ' Pull UPs
DDRD  = &B11110000         ' PD4-7 = output

dim i as byte
dim temp as byte


Waitms 2000

if PINB.0=0 then                 ' button 0 is pressed during startup so entering configuration mode
   print "AT+RESTORE=1"
   waitms 1000
   print "AT+CWMODE_CUR=2"
   waitms 1000
   print "AT+WIZ_NETCONFIG"
   do
   loop             ' halt executing program to prevent mess with configuration
endif

' START A SOCKET CONNECTION
print "AT+CIPSTART={034}TCP{034},{034}192.168.1.10{034},5000" ' AT+CIPSTART="TCP","192.168.1.10",5000
Waitms 1000
print "AT+CIPMODE=1"                                  ' change to singe connection mode
waitms 1000
print "AT+CIPSEND"
waitms 1000
print                                               ' 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
   i = waitkey()
   Select case i
     case 49 : toggle PORTD.4
     case 50 : toggle PORTD.5
     case 51 : toggle portD.6
     case 52 : print bin(PINB)
   end select
loop
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5298
Location: Holland

blank.gif
PostPosted: Sat Aug 28, 2021 3:48 pm    Post subject: Reply with quote

hi plouf

thanks for sharing this. yes wiznet has proven to be a reliable source with good documentation. this seems a great module for a good price. i will order one to test it. wanted to do that before but your post is a good reminder.
the AT set seems common so can be re-used.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum