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: 78
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: 5921
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
AlanGHosler

Bascom Member



Joined: 25 Jan 2011
Posts: 109

usa.gif
PostPosted: Sun Feb 13, 2022 12:57 am    Post subject: More WizFi386 Reply with quote

Thank you for posting your bare-bones example. Have you done more with the WizFi360?

I am interested in how to post text to an email service such as smp2go.com.

Elsewhere in this usergroup I have posted my program for sending data as SMS and photos as MMS email messages. AT&T and others are sunsetting their 3G service. Rather than convert my work to 4G I have decided to switch to a Nighthawk LTE Modem Hotspot Router (MR1100) and send the data out via WiFi.

I do okay on electronic design and coding but I am weak on the network considerations.
Back to top
View user's profile
plouf

Bascom Member



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

greece.gif
PostPosted: Sun Feb 13, 2022 6:57 pm    Post subject: Reply with quote

no, i am working on other jobs currently Smile

however you should have no problem to send email with smtp2go
the following UNTESTED example, normaly whould work
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 to smtp2go
print "AT+CIPSTART={034}TCP{034},{034}103.2.140.82{034},2525" ' smtp2go europe's ip
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

'
print "EHLO" '
waitms 50
print "AUTH LOGIN" ' start authentication
print "MTIzNDU2" ' thats base64 encoded username (123456 in this example)
print "MTIzNDU2" ' thats base64 encoded password (123456 in this example)
print "mail from:you@yourverifieddomain.com"
print "rcpt to:me@email.com"
print "DATA"
print "Message in e-mail's body"
print "."
print "quit"

 

_________________
Christos
Back to top
View user's profile
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