Shop OBEX P1 Docs P2 Docs Learn Events
Need some help to get started with my Spinneret — Parallax Forums

Need some help to get started with my Spinneret

Don MDon M Posts: 1,647
edited 2011-07-11 10:34 in Accessories
I have an idea for my Spinerret but am somewhat confused by some of the terminology and different code objects presented here.

My project involves remotely reading temperatures from several XBee nodes. The Spinneret will have its own XBee to connect with the others. I will read the temperatures at preset intervals to be sent as a message and also monitor for readings that fall into an alarm zone to have a message sent immediately.

What I am looking to do is have the Spinneret store a simple webpage on the SD card that only needs to be available within the network that it is connected to. It doesn't need to be visible outside of this network to the outside world.

The purpose of the webpage is just to set some parameters for setting the frequency of temperature readings and the email address in which to send the data, etc.

The Spinneret will need to be able to send a email message. I also see that Beau (and others) have made it possible to set the clock from the internet time source as well which I would also use to time stamp the readings and messages.

So which objects would be needed here to get me started with say showing a webpage and being able to send a email message?

I want to be able to plug in the Spinneret into a router. Do I need to know anything about the network that it is plugged into in order to send these messages? I would like for it to be as simple as "plug and play" (within reason) if possible.

I need to take this in baby steps to get started.

I apologize for my ignorance here. Thanks for any help.

Don

Comments

  • Brandon_LBrandon_L Posts: 37
    edited 2011-06-01 11:36
    Don,

    Congratulations for getting a Spinneret. I can't claim to know the content of the entire site but I have not seen any projects that send E-mails. I would start with getting a webpage running that tells the time. That can be done with a little work. I do not yet have working code to set the clock & serve a webpage. I got the clock set with one piece of code and then worked out a webpage to show it sepreatly. My work has been based mainly on this:

    http://forums.parallax.com/showthread.php?128747-LOVING-Spinneret-Web-Server-DEMO-v1.2.

    As far as e-mailiing there are a few ways to work this out. One is to write a e-mail server, that would be awesome, the other is monitor a value on your webpage and have some other device handle the alert. For my project I will have the information on a webpage but I've also attached a 4 line LCD that can display information. So to boil all this down - you could design your webpage with a box to indicate the status and readings from each Xbee sensor. The background color of the box could represent the temperature range. If the background color went red a script watching the boxes on a PC could send a e-mail, text message & write a log of when the event took place. I would break it down to the simplest points and start there. There are 2 types of web demos I've seen. Ones that store webpages on the memory card and ones that build the webpage in memory. As for network routing - you will need to decide if you can manually assign a IP address, or if you want the Spinneret to self assign one with DHCP. Is this for a specific network or all networks? Keep in mind the current configuration ( meaning the network port in the Spinneret ) can only handle IPv4 - meaning ip addresses with 4 octets, like 222.222.222.222.

    I hope you find this helpful. If you have any questions about my input please feel free to ask.

    Thanks

    Brandon_L
  • Don MDon M Posts: 1,647
    edited 2011-06-01 12:48
    Hi Brandon-

    Ok that should get me started to display a webpage. I am confused about the email server. I was looking at this thread-

    http://forums.parallax.com/showthread.php?131983-What-s-eating-my-DAT-data&highlight=smtp

    and it looks to me as though Jeff is accessing an email application using the propeller. I was guessing that he was writing some sort of script that the propeller would go to a certain url address on the web, log in and then compose a message and send it. Could it be that simple in theory? Maybe I am looking at this wrong.
  • Mike GMike G Posts: 2,702
    edited 2011-06-01 13:10
    @Don M, You got it, that's pretty much how SMTP works. The username and password are BASE64 encoded. You do need to know a mail server to talk to.
  • Don MDon M Posts: 1,647
    edited 2011-06-01 14:03
    So could one just set up a mail account with say Gmail and use that? I see they have a basic html option.

    I found this information. Might be useful here-

    http://blog.arvixe.com/how-to-manually-test-smtp-authentication/
  • Mike GMike G Posts: 2,702
    edited 2011-06-01 21:09
    Don M wrote:
    So could one just set up a mail account with say Gmail and use that?
    I'm not sure you have to do some research.

    I can send SMTP message via my ISP. I'm a little hesitant to publish the entire working code as that could lead to SPAM. Here's the method that sends an SMTP message.
    PUB SendTestEmail(id) | st, size, tempMask, wait
      tempMask := tcpMask
      tcpMask := SetTcpSocketMaskById(id, 0)
      wait := 200
      Socket.Close(id)
      pause(delay)
      InitializeSocketForEmail(id)
      pause(delay)
      socket.readIND(GetStatusRegisterAddress(id), @st, 1)
      
      pst.str(string(13, "Connecting to mail server",13))
      Socket.Connect(id)
      pause(wait)
    
      repeat while !Socket.Connected(id)
    
      pst.str(string("Connected... Talking with mail server",13))
      StringSend(id, string("HELO agaverobotics.com", 13, 10))
      pause(wait)
      StringSend(id, string("MAIL FROM: <email@email.com>", 13, 10))
      pause(wait)
      StringSend(id, string("RCPT TO: <email@email.com>", 13, 10))
      pause(wait)
      StringSend(id, string("DATA", 13, 10))
      pause(wait)
      StringSend(id, string("SUBJECT: Email from the Spinneret", 13, 10))
      pause(wait)
      StringSend(id, string("Hello from the Spinneret.", 13, 10))
      pause(wait)
      StringSend(id, string(".", 13, 10))
      pause(wait)
      StringSend(id, string("QUIT", 13, 10))
      pause(wait)
      pst.str(string("Done",13, 10))
      
      repeat until size := Socket.rxTCP(id, @rxdata)
      Socket.rxTCP(id, @rxdata)
      pst.str(@rxdata)
    
      'Reset the socket
      Socket.Disconnect(id)
      InitializeSocket(id)
      
      'Reset the tcpMask
      tcpMask := tempMask
    

    A little explanation about the code. My Spinneret uses all 4 sockets for TCP and UPD. The line
    tcpMask := SetTcpSocketMaskById(id, 0) 
    
    takes one of the sockets out of rotation so that it can send a client request while the other sockets do their thing. The socket is returned to a TCP listener at the end of the method.

    This piece of code just initializes the socket to connect to my ISP's SMTP server.
    InitializeSocketForEmail(id)
    ...
    PRI InitializeSocketForEmail(id)
      Socket.Initialize(id, TCP_PROTOCOL, port, emailPort, @emailIp)
      return
    

    The rest should be self explanatory. I hope this helps, let me know if you have any questions.
  • Daniel HarrisDaniel Harris Posts: 207
    edited 2011-07-11 02:28
    Don M wrote: »
    So could one just set up a mail account with say Gmail and use that? I see they have a basic html option.

    I found this information. Might be useful here-

    http://blog.arvixe.com/how-to-manually-test-smtp-authentication/



    I can tell you that Google's mail servers require TLS authentication. I dont know too much about it though. The Propeller would have to be programmed to go through some key generation algorithm...something like that.
  • JeffaJeffa Posts: 80
    edited 2011-07-11 10:34
    Hi Don,

    I've just recently started with the Spinneret myself. I've created a blog, Spinneret Resources, where I have collected a lot of the resources that I found useful while first starting out. It's a work in progress, you may find it helpful:


    My nerdDoro.spin might help some. It accomplishs some things you may need to do. Currently it will
    • Display a Spinneret web page from memory
    • Read and display the RTC on the web page and 4 line LCD
    • Read temperature from Sensirion and display on the web page
    • Allow for an 'LED' button to be clicked toggling the state of the onboard usr led
    The entire project is available on github https://github.com/jhalbrecht/nerdDoro I'm updating it a lot right now as I rough in the parts I need.

    nerdDoroLedTemperature.PNG
    758 x 863 - 147K
Sign In or Register to comment.