How do I use Zigbee to communicate to a laptop? - zigbee

What I have in mind is having a number of sensors (temperature, accelerometer, sound level meter) that are controlled by a micro controller. What I want to do is take this information and transmit it wireless to a laptop that will take this information and put it on to a web server using Zigbee. I don't know where to start.

Since you don't have any hardware as of yet, you might want to give the Arduino a try. The hardware is affordable, can be connected to your system via USB while being programmable in-system.
The basic board can be extended via so called "shields", which offer additional features. In your case, the XBee shield would be appropriate. Connecting your laptop to a XBee module is as simple as using Sparkfun's breakout board and a mini-USB cable.
The Arduino has a large community, so you will find a lot of resources, like books, online material, example code etc.

We also provide wireless modules that can be used for serial data transmission. They can be found at www.starmanelectric.com Our modules are very similar to the xbee, but more plug and play. They can be a great for going wireless for the first time. Our devices are designed to function like a "wireless cable" so if you're used to using wires then you'll be up and running in no time at all. We also have circuit examples for transmitting to a laptop serial port or USB. Any micro-controller will be fine for this application, as long as it has a serial port and a few ADCs to sample your data. Our modules also provide simple analog in/out which can run in parallel to the serial. If you want to compare to other systems, I would google "wireless serial modules"
Regards,
Michael
Starman Electric

Related

How to send binary data (0 volts, 5 volts) through USB?

I'm getting interested in electronics. As a beginner thing, I wanted to try to manually turn on and off my plasma globe through Python code. The globe takes in a 5 volt DC power supply. I can power it through my laptop, which is a nitro 5. So it's sending a constant 5 volts.
I need to communicate with the USB (serial port?). The module Pyserial seems to be the right choice. However, no matter what I try it can't identify the USB serial port. Not even when I plug in a phone. I think it can only identify a COM port, whatever that is. What's the difference? In my device manager, there isn't even a COM port section.
I know it's possible to communicate through that USB port because it can send data to and from my phone, so is this simple thing even possible? Thanks!
Well, the problem is that your plasma ball has most likely not USB interface at all, meaning that from the 4 wires you maybe got inside the cable (rx; tx; GND; 5V) only the 5 volts are used inside the ball to give the HV circuit power.
Other than that, pyserial is a meant to be used for serial communication like devices with RS232 not USB interface.
If i wanted to control the ball from my computer with software i would program an AVR µc to interact via serial communication (probably with an MOS-FET as a switch), from that point on you could use for example your python module to turn it on and of.

Porting Arduino serial communication to standalone atmega328

I have a fairly complex project done on Arduino2560, which I want to port to a standalone Atmega328. My problem is that one feature in the project is that it can communicate with my computer via serial (I made a C# program to handle it on the computer side, using the COM3 port). However, Arduino uses the USB communication for a virtual serial port, and I got a bit confused about how it could be done for the Atmega. It has the RX-TX lines, but what's next? Maybe use some serial-USB converters? What's the best approach for this? Is there anything I should be careful about?
Thanks.
Considering you mention a specific port COM3 on your computer I guess we can assume you have a native RS-232 port (one of those with the sub-D9 male connector that we were used to in the old days but are not so common anymore).
If that's the case, then you can get an RS232 level shifter. You'll just have to make the connections to RX, TX, Vcc, and GND and this device will change the RS-232 voltage levels to whatever your board requires (most likely 5V or 3.3V). Some (maybe most) high-end development boards include this kind of level shifter so maybe check yours in case you already have it (if you do you'll probably see a MAX232 IC somewhere). Or if you are crafty you can also DIY.
If you prefer to connect to a USB port (then, of course, it won't be COM3unless you explicitly change the configuration on Windows Device Manager) you can go for a USB-to-serial adaptor. On that front, you have many choices, starting from the cheapest at maybe 5$, but I'd rather choose one based on the FTDI chip, which is nowadays quite ubiquitous and has proven its reliability. This one is a good example, and at the same cost as the level shifter.
Now, are there any differences between using the native RS-232 or the USB adaptor? The answer is, for most practical purposes, no. If you go to the fine details, like buffer sizes, there will be differences, but if you need to go there you'll need to study the details in both cases to see if the port you have (or the one you're planning to add) meet your needs. For most scenarios, I would choose the USB, if only because you have it everywhere (most laptops don't have a native RS-232).
All of the above (based on RS-232 and/or USB) will work fine for cables running up to 5 meters (~15 ft.) for USB or maybe 10 to 15 meters (~30-45 ft.). This should be enough for most hobbyist or at-home projects. If you want to run longer cables you'll have to go for something like RS-485.
If you choose now the USB adaptor and you think you might need to relocate your board in the future to end up more than 20 meters (15 of RS-232 + 5 of USB) away from your computer just make sure your adaptor includes a TX Enable signal (TXEN). Most adaptors based on the FTDI chip will have this signal on a pin (like the one I linked above), and that will make your life way easier if you want to use RS-485 on a two-cable half-duplex bus.
EDIT: based on the feedback below there is new info that deserves a quick update.
First, you don't have an old school RS-232 port on your PC and second you have to design the connection on the microcontroller's side.
With that in mind it's clear you have to go for the USB solution. But you need to choose if you shift both sides to RS-232 levels or you stay at TTL. That decision depends again on the length of your bus. If it'll be really short (up to 2 meters) then you can stay on TTL, otherwise better shift to RS-232 to be on the safe side. There are many people who will tell you they have much longer serial links but how reliable they are you'll never know.
Since you have to design the board, I guess it makes sense to integrate the MAX232 and a sub D-9 connector there and get the cable you mentioned for your PC.
Or, you can add only a connector on the board and get the Sparkfun level shifter I linked above for the micro's side plus the same USB to RS-232 for your PC.

Best way to transfer data from Arduino to Server

I am new to Arduino and I would like to do a project that sends data, remotely. So, the Arduino would not be connected to Wifi/Bluetooth, Ethernet, etc. Would using a GSM shield be the best way to transfer data? I do not need to make phone calls or send SMS (unless sending SMS would be a better, more reliable, option) just data to a server, who's app I would create. If this is the best option, what else would I need to make this happen? For example, on top of the GSM shield (I am looking at something cheap like this: https://www.amazon.com/Geeetech-SIMCOM-Quad-band-Development-Arduino/dp/B00A8DDYB6/ref=sr_1_2?ie=UTF8&qid=1467651878&sr=8-2&keywords=Arduino+GSM+Shield) what other charges would I need to pay? I.E. would I also need to get another phone plan? Would I have to pay for a gateway service that would receive the cell phone data and then send it to my server?
Thanks your any thoughts on this
Wifi, ethernet or GSM, it depends on what you want to use, and what you have.
With all three you can send data to a server.
There is a bench of Arduino shields. All shields from Arduino come with a library to handle communication.
Other shields from other vendors exist and they provide their libraries too.
For Ethernet you can check the arduino shield https://www.arduino.cc/en/Main/ArduinoBoardEthernet.
For Wifi there are plenty. You have first the arduino shield. You can also take a look at the CC3000. Or the famous ESP8266. For all three you can find libraries.
For GSM, Arduino has a shield and a library. Arduino uses the Quectel M10 GSM moduel. You can find lots of examples in the arduino website and all over the net (https://www.arduino.cc/en/Guide/ArduinoGSMShield).
There exist other shields like the one you mentioned. Libraries does exist for those "other" shields however they are not as maintained as the arduino one.
You need to be careful though, you'll find over Amazon (and most likely on Alibaba) some GSM modules like SIM900A that are way cheaper, those are only dual band and will work only on certain contries.
There is another cheap GSM Module called the A6. It was made by espressif the company behid the ESP8266. It's relatively new and no library exist for it at the time. You can write you own functions to use it, but that would be some extra work.
In all cases, to use a GSM module you'll need a sim card with it's phone plan and all.
Another thing to consider is how to power these shields. They use more power than an Arduino can generate (A GSM modules datasheet recommend to use a power supply that can deliver up to 2A). If you power them straight from the Arduino, you may encounter some strange behaviour.
So the ideal way is to have for them an external power supply with the required amps and have a commun ground with the Arduino.

AVR Atmega8 Serial Communication

I am posting this question after not getting any sort of help across the web and reading many articles and tutorials. I ended up asking questions with hope of getting guided.
DESPERATE FOR HELP.
What i want:
1) I want to build a R/C tank.
2) Basically its not controlled by a remote control but i want control by a laptop.(i could write a c++ or c# program).
What i know:
1) I know how to develop a development board. (i want to develop my own, not use arduino)
2) I know c++ and assembly very well.
3) I know about AVR's ALU, Memories(all 3), Stack, Interrupts, IO Operations well.
4) I know theory about how SPI, RS232, UART works.
PROBLEMS: (I have many questions, but most important are)
1) B/c i have made my own board. How can i transfer my program(hex file) to my board(i seek practical and physical implementation, not theory please)(i know about a 6-pin ISP but not clear about practical implementation)
2) After it, how can i make wireless communication b/w my AVR and laptop.(hardware device?)(SPI, RS232, UART?)
MAIN CONFUSION:
1) I cannot help myself differentiating or relating SPI, RS232 and UART.
I know these are used for serial communication between devices but how?(which is used when and why and how)(appropriate hardware for transmitting device and receiving device)
THING TO KNOW:
1) I haven't started making my board and programming it because i think i should learn everything first and then do it in a one go. OR should i start practical work and things get easier automatically??
2) I learnt a tutorial series on Serial Communication from http://maxembedded.com/2013/09/serial-communication-introduction/ the starting 5 topics leaving the last one(I2C). Am i missing something there?
I hope everything is clear, and waiting for a good-men's words.
Note: I am already very misguided and lost, so i want experienced and expert's guidance. Many Many Many Many Thanks in Advance.
MY BOARD LOOKS LIKE:
http://www.robotplatform.com/howto/dev_board/schematic_l/38.jpg
1) To upload your code into AVR chip, you can use ISP interface. That requires you to connect at least 5 pins: SCK, MISO, MOSI, RESET, GND, and optionally VCC (it used to control or supply voltage, but not mandatory, if your board has it's own power supply). All you need is just to wire 6- or 10-pin ISP connector to that pins of your CPU.
To begin programming process you need to obtain some programmer device (USBasp, AVRISPmk2, STK500/600 etc.), Also, you can use Arduino board itself as ISP-programmer for external AVR chip, like this: http://www.instructables.com/id/Programming-an-ATTiny13A-using-Arduino-servo-int/
Each of programmer model requires it's compatible software (such as PonyProg), for example STK500 and AVRISP programmes could be used directly from Atmel Studio.
Also, you can connect ISP to parallel (LPT) port of the PC, and upload firmware using specialized software, such as uniprof
Another way to upload software - it is to make your own bootloader - a tiny program that will update firmware, using any available interface.
2) USART, SPI, I2C - it is different interfaces to communicate with peripherals. Note that RS232 - it is electrical interface built over USART. I.e. you need external IC which will convert USART logical level signals to RS232 electrical levels.
each of that interfaces have it's own profs and cons. And usually selection of which interface to use depends on which interface is supported by peripherals.
SPI - it is interface for high-speed communication. One master many slaves. It requires a lot of wires: MISO (data from master to slave), MOSI (data from slave to master), SCK (clock) - those three could be common for all slaves. Also it requires a SS (slave select) - one SS wire for each slave to determine which slave is in communication at the moment, also it sets the edges of the data packet.
USART - it is common interface, to communicate two chips. Each byte transmitted with foregoing start bit, optional parity and following stop bit. I.e. transfer has a quarter overhead, but byte can be transmitted in any moment.
Works in synchronous and asynchronous modes. Asynchronous mode requires only 2 wires (RX and TX, not counting GND that also required). This mode requires that receiver and transmitter to be sychronized, in most cases that required to crystal oscillator to be installed.
Synchronous mode works in the same format as asynchronous, but have additional XCK (clock) wire, that determines in which moments bits are possible to be transmitted. This allows to increase transmission speed and not requires time precision from receiver. Synchronous mode is rare used.
I2C - it's a bus with only two wires, allows many masters and many slaves. Utilizes pull-up resistors to achieve wired AND, have it's own algorithm to detect collisions, more complicated to be programmed, transmission speed is limited.
Often used by peripherals, such as accelerometers, RTCs etc.
AVR chips have no it's own support for wireless communication, therefore, to do that you need to use some external wireless chip, for example bluetooth, or WiFi, there are a lot of such modules (for example ESP8266). AVR chip communicate with them using USART, sending and receiving simple commands.

Arduino wireless communication

So what is the easiest way to get started? There are so many options available it's hard to decide, from a beginner's standpoint, which is the best.
What is the best option for simple wireless communication? That is, communication from a controller to move a robot, or from an arduino to relay information back to a computer for processing.
Drawing from your experiences, what's the 'best' option in your opinion?
Bluetooth would be the most flexible, however I believe xbee to be the easiest. Software wise xbee is exactly the same as serial an even allows for wireless reprogramming and the higher end ones have some serious range.
Bluetooth can be easy if you have a Bluetooth device you're trying to talk to (e.g. Mac-book or Smartphone). The problem is that Bluetooth radios for the the Arduino are still (in 2013) expensive. A Bluetooth radio usually costs more than an Arduino! Low Power Bluetooth may be an option as well. Essentially, Bluetooth is a simple serial transfer of data so you have to create your own protocol on both sides.
Bluetooth Low Energy BLEis an emerging technology and is available on some new devices (recent iPads, macbooks etc: Supoorted Devices ), this may or may not meet your requirements.

Resources