In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use micro:bit, XinaBox and IoT to achieve data capture. I think it is very practical, so I share it with you. I hope you can get something after reading this article.
The accelerometer data is captured remotely on the BBC micro:bit and then transferred to the IoT platform using the XinaBox Wi-Fi gateway.
The materials needed
XinaBox IP01 x 1
XinaBox CW01 x 1
XinaBox BM01 x 1
XinaBox XC10 x 1
BBC micro:bit x 1
Software and online services
Free IoT platform for Ubidots,30 days.
Story
Acceleration is the reason why an object changes its speed: acceleration occurs when a force of sufficient strength is applied to the body and decelerates, accelerates, or changes direction. This is our basic observation of the world. Not only the experience is simple and intuitive, but also the analysis is very attractive and educational. You can visualize the forces associated with dropping or throwing a ball or accelerating a rocket, or see what happens when a moving object hits a wall.
This project will show you how to use micro:bit and IoT to analyze acceleration over time. You can use the code and techniques described here to measure the acceleration of moving objects for micro:bit.
Here is an example of acceleration visualization: the chart shows the actual data of an object moving in a plane. I won't say much to it right now-I encourage you to look at the acceleration curve and try to infer what happened (for example, is it a ball bouncing, or rolling, or something? ). The last part of this article reveals the real-world events shown below.
One of the great features of BBC micro: its onboard accelerometer. Many young learners spend a lot of time reading data from accelerometers and using it in a variety of creative ways. I have seen countless remote control cars, gloves as controllers, some very smart balancing robots, and even gesture-based music 'musical instruments'.
However, as a learning tool, accelerometer also has great potential to support the trigonometric function of speed / distance / time. This triangle is very important and appears to be a field of knowledge in physics. What better way to teach acceleration than to let young learners witness an event and then review the power behind that event?
In this article, I will show you how to:
Use micro:bit to collect a bunch of accelerometer readings. This micro:bit will collect data "remotely", which means it will collect data during the event and store it in micro:bit for later sharing (I'll explain why later).
Once the event we measured is complete, we will use the Wi-fi-based micro:bit XinaBox IoT starter kit (what I call our micro:bit gateway here) to get the data and transfer it to the Internet of things platform.
In this example, we will throw a ball between two people and transfer the data to the Ubidots IoT platform.
Why collect raw accelerometer data remotely?
The micro:bit includes wireless capabilities that enable a Bluetooth connection between the micro:bit and another device (not another micro:bit).
In some cases, you can use radio or BT to transmit data when collecting data. This method is not suitable for the situation that leads to this blog. When I was asked to look at the real-world problems that generated the chart at the beginning, I needed to consider some specific challenges:
It is important that the data is not lost. I need to store the data during the run time and then extract it. I can't afford wireless packet loss or BT connection loss. Saving data during the run means that we can retrieve it when we are free, and if the data retrieval fails, we can try again.
For some of the reasons I will explain later, I want to use all the processor time to get the accelerometer readings during the acceleration event (which I will call it running later). If I transfer data during run time, it will reduce the amount of data we can sample, which will affect the quality of the data.
I want to store a lot of data, so I need to make sure that unnecessary processes use the least amount of memory. A production-level data collector (not included here) ensures that microbit's data is extended to its limits!
An object moving in motion may have moved a considerable distance, and it is risky to put the receiver in a fixed position. Think of it this way-the code here can be used to measure the acceleration of a body that falls from a height. The code can be used to read data for 10 seconds or more, and during that time, it will fall a long distance from where you dropped it.
I have completed the following workflow:
Make a measurement
Write additional microPython code to micro:bit.
Connect to battery
Cut a hole big enough in your ball to fit the microbit and battery.
Fill the space in the ball with fillers (I used bubble film)
When you are finished, do the following to activate it:
Click the reset button to clear the old data, and then click the A button
The countdown starts at 3-at the end of the countdown, the LED shows a stop, indicating that the microbit is measuring. In the meantime, throw the ball.
When the measurement phase is complete, a small square appears on the LED. The sample code records data for about 3 seconds, but you can adjust the code to increase or decrease the data.
When you click the B button, it initiates the transfer of data to the micro:bit gateway.
There are two versions of the program, Simple and Advanced, and the difference between them is the method of data collection. Both save data once per 25ms (equivalent to 40 times per second), for the Simple version, we only read the accelerometer once per 25ms, while the advance version will read the accelerometer up to 75 times during the 25ms cycle, and then we save a value, the average of all 75 readings, so that the data can be "smoothed": it reduces outliers and provides maximum approximation of acceleration over the entire 25ms cycle. To understand the differences in data quality, I suggest you try it yourself: use two versions of the code and look at the data chart. You can read more details about this method, when to use it, and why it works.
If you look at the code, you'll notice that I record the acceleration on the y plane. Because for the real-world scenario where I developed this program, micro:bit moves in that plane. However, when it comes to throwing the ball, the force acting on the y plane is the component in the direction of throwing microbit. You can adjust the code to record the x and z readings, and the way you can throw the ball so that the acceleration is on the plane you are recording.
You may also notice that the code needs to provide 120 readings. Read once per 25ms, which is equivalent to 3 seconds of data collection, and I found that up to 400 data points can be recorded in this way. I use files to store data instead of lists. Both approaches have their own advantages and disadvantages, and I won't repeat them here (but you can ask questions if you are interested).
Microbit Gateway + Internet of things platform
You need to do the following:
Build and set up the micro:bit gateway.
Connect to the Internet of things platform
I recommend that you check out this blog, which contains all the information you need to connect.
Before completing the lab, make sure that your gateway is powered up and connected to the Ubidots.
Note that the microPython code in the gateway for this project is almost the same as the code used in other blogs I've written. It is relatively easy to adjust for each case, when programming with MakeCode graphics (coming soon! This process will be greatly simplified
Put them together.
As mentioned above, set up and throw the ball.
When the measurement is complete, make sure that the microbit in your ball is within the range of the gateway (it should be a few meters).
Make sure your gateway is ready to receive data.
Click the B button on the ball
Sit down and watch the process. It's interesting to watch the data accumulate on Ubidots.
It takes about a minute for my code to transfer all the data to the IoT platform. This time can be significantly reduced. The reason it took so long was that I was very cautious-it took me some time to adjust the delay, and when I found that the effects were consistent, I gave up. I'd love to see it work faster, so if you achieve this, please contact me and let me know how to do it.
Analyze the chart from scratch
Let's take another look at the chart at the beginning of the blog. This time, I have set some lines to mark interesting "phases":
Phase 0: the object is at rest.
Stage 1: rapid acceleration (even explosive). It reaches its peak at the marked point, but during that time the object accelerates. At the end of this period, the object has reached its maximum speed.
Stage 2: at the beginning of this period, the deceleration of the object exceeds the acceleration force and begins to decelerate rapidly.
Stage 3: the data here are a bit "noisy"-objects are decelerating most of the time, and the occasional change in deceleration is interesting.
Stage 4: a rapid deceleration occurs, and the speed also decreases rapidly until it reaches zero.
Stage 5: the object is at rest again.
Have you guessed what it is?
This is a rocket-powered car. In the first stage, the rocket engine caught fire, then stopped launching, and we entered the second stage. At this stage, we can see that the resistance has an effect on the vehicle. In stage 3, the car bounces a little, sometimes off the ground and briefly into freefall (which may explain the slight acceleration found during that period). In stage 4, it will hit a specially designed buffer system and slow it down to a stop within a range of about 1.5 meters.
The above is how to use micro:bit, XinaBox and IoT to achieve data capture. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.