[Solved]Questions about wifi module and SD card

Discussion in 'UDOO 101' started by maatong, Apr 7, 2014.

  1. maatong

    maatong New Member

    Joined:
    Apr 3, 2014
    Messages:
    16
    Likes Received:
    0
    Hi everyone:
    I'm a beginner of UDOO, and I have two questions about the board.
    First is about the WIFI module, in my project, I need the board to connect to the wifi, and commands are sent and received between boards, so I need some functions or commands of the WIFI module so that I can put them in my program, does it have these functions that I can use like code lines?
    And for the SD card, the information list reads that, the SD card is for booting, so my question is that, can I also put some data like some pics or sound files, and use these data in program?

    Thank you very much.

    Best regards.
    Yini Guo
     
  2. peter247

    peter247 New Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: Questions about wifi module and SD card

    The easy way to think about it is you have a Table computer connected with a Arduino via serial.
    So the arduino / sam part does not have any direct access to the Wifi / Ethernet or SD card but need to communicate to the Table computer via serial to get access.

    There are many way to access Wifi / Ethernet it all depends to what you what to do.
    My way, I do it is by using python and socket or http libraries.
    With python libraries , you can make a web server in a few lines of code .

    You can store whatever you like on it , music , films , programs

    It`s like saying c: drive on windows is the boot drive !!!!!
    It just means that the drive it boot from , not that it is only used for boot !!!!
     
  3. maatong

    maatong New Member

    Joined:
    Apr 3, 2014
    Messages:
    16
    Likes Received:
    0
    Re: Questions about wifi module and SD card

    Hi peter:
    Thank you for the respond.
    now I get the functions about the SD card.
    And for the wifi module, I can get the "table computer" accessed to the wifi with the wifi module by some codes, and which kind of the config code depends on which program platform I use, did I get it right?

    Yini
     
  4. peter247

    peter247 New Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: Questions about wifi module and SD card

    I may be having problems with "lost in translation" I`m not sure what you mean !!!!!

    Getting access to the Wifi / Ethernet is the same on any development board , Raspberry PI , SheavaPlug , beaglebone which is running full linux , via a programming language , So you will need to learn a programming language to be able to access the hardware.
    On a Arduino side you will have to learn a little c++ / c , But on the iMX.6 CPU side it`s upto you what programming language you wish you use c , c++, basic , java , python , pascal etc

    What is your end goal ? , what are you trying to achieve ?
     
  5. maatong

    maatong New Member

    Joined:
    Apr 3, 2014
    Messages:
    16
    Likes Received:
    0
    Re: Questions about wifi module and SD card

    Hi peter:
    The goal I want to get is that, I want to build a system of several UDOO boards, and I need them to connect each other and send/receive message to/from each other with wifi, and these needs to be achieved by code lines.
    I can do it with C program right?
    I never do wifi program before so is it possible to find some examples on line? I found some instructions from Raspberry PI website for linux wifi setting, can I apply them on UDOO board as well?
    Thank you very much.

    Yini
     
  6. peter247

    peter247 New Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: Questions about wifi module and SD card

    After you have set them up , Wifi and Ethernet are basically the same , just two different methods to get the same result.
    Setting the WiFi up on the raspberry Pi may be a little different to configure , because they are using different WiFi adapters.
    After you have got them working ( Wifi or Ethernet ) you can use any programming language to get access to them , c++ or python eg , I like python because you can achieve the same results in only a few lines of code.

    below is a simple test program I made for the raspberry pi , for one computer to send data to the other via the network , which should give you a clue how easy it with python .

    Code:
    #!/usr/bin/env python3
    
    import quick2wire.i2c as quick
    from quick2wire.i2c import *   
    
    import sys
    import socket
    import time
    
    HOST = "127.0.0.1"
    PORT = 50007
    
    def send(  my_str , p_out = True ):
    	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    	s.settimeout(1)
    	s.connect((HOST, PORT))
    	try:
    		# send "Hello"
    		s.send( "Hello".encode('utf-8') )
    		# receice , and check for "ok" or exit 
    		data = s.recv(1024)
    		if data.decode('utf-8') != "ok":
    			print ( data.decode('utf-8') )
    			s.close()
    			sys.exit()
    		
    		# send command set and check for "ok" or exit
    		s.send( my_str.encode('utf-8') )
    		data = s.recv(1024)
    		if data.decode('utf-8') != "ok":
    			print ( data.decode('utf-8') )
    			s.close()
    			sys.exit()
    		
    		# send anything to trigger incoming data
    		s.send( " ".encode('utf-8') )
    		data = s.recv(1024)
    	
    		if p_out: print (data.decode('utf-8'))
    
    	except socket.timeout as exc :
    		print ("The other side is waiting for") 
    
    cold = input("Cold temp value ? ")
    hot = input("Hot temp value  ? ")
    		
    if cold: send ( "write cold " + str(cold) , False ) 
    if hot: send ( "write hot " + str(hot) , False ) 
    send ( "read" )
    
     
  7. mkopack

    mkopack Member

    Joined:
    Jun 14, 2013
    Messages:
    451
    Likes Received:
    21
    Re: Questions about wifi module and SD card

    The important pieces of that example code are the ones related to creating the socket connection between this computer and another (ie, the network link) and then the socket's .send call to push the data across the network.
     
  8. maatong

    maatong New Member

    Joined:
    Apr 3, 2014
    Messages:
    16
    Likes Received:
    0
    Thanks to Peter and mkopack.
    Problem solved.
     

Share This Page